In certain applications it is important that the time of reception of a data. item is known. For example, this applies to open- and closed-loop control engineering where measurement data are used for controlling a process. The older a data item is, the worse it is as control data. In most cases, data can be processed quickly and effectively in the computer so that the delay becomes so small that it does not need to be considered. In these systems, it can be said that the data is provided with its time determination by the fact that the system is built up with a time delay which is so small that it can be neglected. In a system which works asynchronously with a data communication system, these transfer times can become long and undetermined in their length. Moreover, it is no longer a question of exact transfer times, but the transfer normally occurs with a certain time probability and with a certain spread based on what loading there is on the communication system and possibly what priority the message has. It is possible to organize the system with strict rules so that the transfer times are guaranteed. But this requires a well developed management which operates through all connected units. One of the reasons that a data communication system is used is to cut down on management, which is why this is a poor solution. Moreover, any reconfigurations require great expenditures. The best way to avoid management is to ensure that all units take into consideration the fact that the data comes randomly in time. For the units to be able to take into consideration variations in time, the receiving unit must know when the data is received in time or how much time the transfer of the data took. Moreover, if the position of the data in time is known, the receiving unit can check that the data has arrived within the arranged time frame. In the construction of a control system, it can be difficult to estimate and/or simulate all possible time delays, but these unexceptable delays can be detected with the aid of time information. At present it is uncommon for the position in time of the data to be included in process control, even in a system with a common clock where this is simple to carry out.
Time uncertainty is not unique to communication systems but also applies internally in a computer, for example a program can read an A/D converter every time it receives an interrupt. If this interrupt does not have the highest priority or a program has disabled the interrupt, it can take a certain time from the arrival of the data to when the data is processed in some program sequence. For this to function with a high accuracy, the data must be accompanied by the time when the data was received. In this way, the subsequent processing program can take into consideration the time of the data arrival. When different clocks are used, these must be synchronized so well that the error between them does not cause any problem for the program sequences which use the time as reference.
There are at least two reasons for ensuring the data position in time before it is processed. A better value than that which has been obtained can be extrapolated from earlier data through calculations. This extrapolation requires that the position in time for the given data is known for the calculation to have good accuracy. The program which will deal with the data can check that it has been received within the correct time. In the case where the data is old, new data can be requested, and in the worst case an error message can be given and/or the process terminated.
To obtain the time in a computer system, a resonant circuit constructed of coils and/or capacitors and/or crystals is used. Crystals are most common since they provide the best accuracy. With a crystal, a stable frequency is obtained which normally has an accuracy between .+-.25 and .+-.2000 ppm of the desired fundamental frequency. The error in the fundamental frequency occurs partly due to geometrical errors in the making of the crystal and errors which occur with varying temperature. These pulses can be counted with a definite frequency with the aid of a counter circuit and a reading of this counter directly provides a time. When the time is to be used, it will normally be specified in terms of seconds so that it is understandable to a person. This raises a problem since in many cases the fundamental frequency of the crystal is not such that the number in the counter directly provides the time in seconds, which is why some form of scaling of the number must be carried out.
Irrespective of the type of time indication, the same type unit must apply to all units which are coupled to a system in which the synchronization of an instant in time is to be possible. The simplest way to solve this is for all units to use a crystal having the same fundamental frequency. In this case, all units receive the same time in their respective counters except for the error which occurs due to the error in the fundamental frequency of the crystal.
To provide an example of how much the error in the local clock can be, it will be described for a crystal having a tolerance of 100 ppm. This tolerance has the result that, at a maximum, the clock loses 0.1 ms for each second. The comparative units can lose the same amount, which has the result that the total increase in error becomes 0.2 ms per second when a crystal with this tolerance is used. By adjusting the clocks in each unit, they can be made to follow a common time base more closely. A single adjustment has the result that the clock loses 1/10-1/100 of the original error. In this way, the erroneous increase can be reduced to become 2-20 microseconds per second. This means that a system with transferring of the main clock by means of hardware can be provided with a common time within .+-.5 microseconds or better with adjustment, even if the main clock is only transferred once per second. As is understood from the description, the error in the clocks consists of two errors, one which occurs due to there being a certain uncertainty in the setting of the clocks and one error which occurs due to the clocks losing relative to one another thereafter.
With such a construction, the clocks are provided with the same time with an error between the clocks which, at a maximum, increases at 2 ms per second. By setting the clocks to the same time every second, the error between such clocks can be held to less than 2 ms. If the units have different crystals, a problem also arises, and this is to obtain the same time base in the counters so that the different units can be provided with comparable time indications. To be successful in this case, the units must in some way correct the frequency or the result which is read from the counter. This can be done by the pulses from the oscillator being divided down in some suitable way or by the number in the counter being scaled and transferred to another register where the common time is obtained. For this to function, the different units must be provided with information about the scaling factor which will be used. This can be done in a number of different ways. Either the units have been programmed with the scaling factor which will be used, or this information is transmitted from some other unit. For this to function, certain information about the oscillator frequencies of the units must be known from the beginning. Another method is that the units calculate the scaling factor by utilizing the method of transmitting the time. By transmitting two main clock times, the receiving units can compare the difference between these times with the difference which has been obtained in the internal clock between the two transmitted times. The scaling factor can be calculated by means of these two time differences. The longer the time which elapses between the transmissions, the higher the accuracy with which the scaling factor can be calculated.
The method of giving the different units a scaling can naturally also be used where the units are equipped with the same fundamental frequency. This gives a more general system where the next unit which is coupled to the system can perhaps have a different frequency which must be scaled. Another reason can be that another time base can be desirable, for example that the time will be indicated in seconds.
In modulizing programs and/or control computers, there are difficulties in solving the time problem. In a small computer system, the program sequence can be so small that all possible paths are known and the maximum delay can be determined. In the case of a modularized program which is executed in a `real-time operating system`, there is always some uncertainty with respect to the time at which a program module will be executed. Even if all programs are given priority and sufficient time allocation, only the program or programs with the highest priority can obtain guaranteed access time. The other modules have to wait for different lengths of time depending on how hard the system is loaded by those with the higher priority.
The problem with the time uncertainty of the data in a computer with a real-time operating system is solved simply when there is a common clock in the system. All that is necessary is that all modules which read data also read the time and couple it to the data.
The problem becomes greater when a multiprocessor system is used where each part system uses its own clock. The simplest way to obtain a common time is to drive the clocks by using one and the same oscillator frequency for all clocks. This limits the problem to setting all clocks to one and the same time once the system starts up. After that, the clocks track the common oscillator.
The problem is accentuated if not all units have access to one and the same fundamental frequency. Not only must the time be set when the system starts, but all clocks must be corrected at certain intervals so that the time difference between them does not become too great. In this case the problem first arises of which time is to be applied. One of the clocks must be selected as `main clock` which provides the time which is valid for the system and which is used to set the other clocks. In a network there can be several main clocks if there are several systems coupled to the network which are independent in time. Another problem to be solved is that the time of the main clock should be transferred in such a way that the other clocks are set to one and the same time with sufficient precision. In most cases, correction of the transmitted time data is required since the transmission time is often greater than the permitted difference.
The above fact requires that, in a system with several clocks, it is clearly determined which of the clocks shall be considered as the right one. In control applications, it is very often not the absolute time which is important, but it is important that the time between two event can be measured with sufficient precision. There is frequently no problem in obtaining the absolute precision, which is why largely any computer clock can be used. The choice of a main clock is therefore most often made on the basis of which module is the `master` in the system.
The above problem with transferring and setting to the same time can cause some problems since this requires great knowledge of how the transfer of data looks in time. This is because it must be made clear how long a time the transfer of the main clock time takes from the reading of the time by the `master` to when the receiver receives the time data. The receiver, in turn, must know how long it takes from the reception of the time data to when its clock is set. The time uncertainty in these transmissions directly appears as error between the main clock and the time indication of the local clock.
The present invention provides a possibility of adjusting the time in each unit to one and the same time with high accuracy. This time is then Used to synchronize the reading-in of the data with this common time. With the aid of this time, the unit which is processing data can compensate for the delay and/or variation in the delay which occurs from the reading of the data to when the data is processed in the receiving unit.
The problems are further accentuated when serial data communication is used. Not only are the parts modularized and operate asynchronously, but they will compete with one another for outputting their message on the relatively slow serial communication channel.
To enable a serial communication to be used at all in an open- or closed-loop control system, it must be fast. This is because data can never be obtained more quickly than the time it takes to transfer data. To increase the speed of communication for important data, these must be given preference in a communication system. One way to solve this is for only certain messages to be sent. Another method which results in less system work is that in which each message is provided with a certain priority in the communications system. It is however only the message with the highest priority which has a guaranteed transfer time. All other messages are dependent on how many messages with higher priority there are and how often they are sent (compare with priority in a computer with `real-time system`). One way to minimize the delays is to make it extremely fast so that a lot of free time is obtained in the communications. However, a faster system becomes prohibitively expensive.
For example, there can be a message which is not directly time critical, which is why it is transmitted with low priority. When this message is transmitted, it can sometimes arrive in 0.08 ms and the next time after 10 ms. It is quite possible to be able to compensate a delay of 10 ms but not a variation between 0.08 and 10 ms. The more messages with higher priority than that to be sent, the greater the spread in the transfer time. This spread and the probability of the transmission of a message occurring within a particular time are based on how often and how many messages of higher priority are transmitted in the communication system.
Irrespective of the solution used, it remains that the receiver cannot determine the transfer time irrespective of the priority of the transferred data. Even the one with the highest priority has a variation in the transfer time depending on whether it is accepted or not and how fast it becomes free.
There are two typical solutions to the problem and the first one is to synchronize the transmissions in the system in some way. However, this will produce a high degree of management effort with regard to what happens in the communication system and a change in a subsystem will in most cases affect all other units coupled to the communication system. This solution is not therefore desirable. The other way is to determine the transfer times which occur. Even if there is no good way to obtain defined transfer times, it is still possible to obtain knowledge on which transfer times apply in each data transmission. This is achieved by each unit being provided with a clock which indicates the time. These clocks are set to the same time, after which the data can be related to this common time.
The problem is to get the clocks to be provided with the same time without introducing further lines in addition to the serial data communication system. If further lines are introduced over and above the communication line, the advantages of serial data communication disappear.
It is possible to implement the time adjustment in all types of serial transmission. However, there is a fundamental requirement which is that the delay of each bit is not too great between transmitter and receiver. In certain cases, it can be possible to compensate for this delay if it does not vary with time. It is also not possible to apply the method if some type of `spooler function` occurs in the communication system, where the delay in the communication channel is not known in advance. For the types mentioned here where the data communication is used for machine control, the delay is only a fraction of the time which it takes to transfer one bit.
Some different types of transmission shall be mentioned here which can be used with the synchronization method described. For all the communication methods described, the function is optimum if the time handling is built into the communication unit. In many cases, however, a general communication unit can be used in accordance with the method described in the general case. For example, the following principles can be used: random, token, polling, termination with polling, allocation of physical priority and so forth.
The best way to protect the transmission against interferences is to use an optical transmission, but at present it is difficult to use this in a bus communication system and there are only some prototypes and these often at a high price. However, it will be possible in the near future to have several receivers and/or transmitters coupled to one and the same optical conductor. If an electrical transmission method is used, it must be carried out in such a way that the different units connected to the data communication system are galvanically separated from one another. This galvanic separation is usually carried out by means of transformers. Another method is to use an opto-coupler between the communication line and the units. To obtain a fast transmission frequently requires electronic circuits in the part which is galvanically coupled to the communication line. These electronic circuits can, however, have a separate voltage feed so that the data communication system with communication electronics is galvanically separated from the units which use the communication system.